package com.study.leetcode;

public class Solution_551 {
    public boolean checkRecord(String s) {
        boolean res = true;
        char index;
        int late = 0;
        int attendance = 0;
        int length = s.length();
        for (int i = 0; i < length; i++) {
            index = s.charAt(i);
            if (index == 'L') {
                late++;
            } else {
                late = 0;
            }
            if (late >= 3) {
                res = false;
                break;
            }
            if (index == 'A') {
                attendance++;
            }
        }
        return res && length - attendance < 2;
    }
}
